<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8"/>
    <title>添加</title>
    <link href="__STATIC__/component/pear/css/pear.css" rel="stylesheet"/>
</head>
<body class="childrenBody {:dialog_css()}">

<form class="layui-form" action="{:url('add')}" method="post">

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">类别</label>
        <div class="layui-input-block">
            {:form_radio('type_id', '可选字段|必须字段|自增ID', 0)}
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">标签</label>
        <div class="layui-input-block">
            <input type="text" name="label" lay-verify="required" placeholder="标签名" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">类型</label>
        <div class="layui-input-inline w150">
            {:form_select('field_type', config_get('cms.field_type', []), 'varchar')}
        </div>
        <div class="layui-form-mid"> 长度</div>
        <div class="layui-input-inline w100">
            <input type="text" name="field_length" placeholder="字段长度" value="20" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">标题</label>
        <div class="layui-input-block">
            <input type="text" name="field_title" lay-verify="required" placeholder="中文字段标题" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-form-item-required">名称</label>
        <div class="layui-input-block">
            <input type="text" name="field_name" lay-verify="required" placeholder="英文字段名称" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">默认值</label>
        <div class="layui-input-block">
            <input type="text" name="field_value" placeholder="留空为''，null为不设置" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">其他</label>
        <div class="layui-input-block">
            <input type="hidden" name="is_required" value="0">
            <input type="hidden" name="is_unsigned" value="0">
            <input type="hidden" name="is_index" value="0">
            <input type="checkbox" name="is_required" title="必填" value="1" lay-skin="primary" checked>
            <input type="checkbox" name="is_unsigned" title="正数" value="1" lay-skin="primary">
            <input type="checkbox" name="is_index" title="索引" value="1" lay-skin="primary">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">注释</label>
        <div class="layui-input-block">
            <input type="text" name="field_comment" placeholder="注释 默认：标题" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">显示</label>
        <div class="layui-input-block">
            <input type="hidden" name="show_list" value="0">
            <input type="hidden" name="show_add" value="0">
            <input type="hidden" name="show_edit" value="0">
            <input type="checkbox" name="show_list" title="列表" value="1" lay-skin="primary" checked>
            <input type="checkbox" name="show_add" title="新增" value="1" lay-skin="primary" checked>
            <input type="checkbox" name="show_edit" title="编辑" value="1" lay-skin="primary" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序值</label>
        <div class="layui-input-block">
            <input type="number" name="sort" value="100" min="0" step="10" lay-affix="number" placeholder="数字排序值" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>

<script src="__STATIC__/component/layui/layui.js"></script>
<script src="__STATIC__/component/pear/pear.js"></script>
<script>
    layui.use(['aphpForm', 'aphp', 'form'], function () {
        var aphpForm = layui.aphpForm,
            aphp = layui.aphp,
            form = layui.form;

        //aphpForm.bindEvent('form.layui-form'); // 渲染表单

        form.on('submit(save)', function (data) {
            aphp.request.postForm(data, 0, function () {
                parent.layer.close(parent.layer.getFrameIndex(window.name));
                parent.layui.table.reload('currentTable');
            });
            return false;
        });
    })
</script>
</body>
</html>